package com.example.controller;

import co.elastic.clients.elasticsearch._types.Result;
import co.elastic.clients.elasticsearch.core.BulkResponse;
import co.elastic.clients.elasticsearch.core.IndexResponse;
import co.elastic.clients.elasticsearch.indices.GetIndexResponse;
import com.example.system.service.EsService;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;

/**
 * @Author 王鹤蒲
 * @Date 2023 12 26
 */
//@RestController
//@Api(tags = "ElasticsearchAPI", description = "提供Elasticsearch操作相关的 REST API")
//@RequestMapping("/es")
public class EsController {
//
//    @Autowired
//    private EsService esService;
//
//    @ResponseBody
//    @RequestMapping(value="/createIndex",method = RequestMethod.POST)
//    public boolean createIndex(String indexName) {
//        return esService.createIndex(indexName);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/queryIndex",method = RequestMethod.POST)
//    public GetIndexResponse queryIndex(String indexName) {
//        return esService.queryIndex(indexName);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/isIndexExist",method = RequestMethod.POST)
//    public Boolean isIndexExist(String indexName) {
//        return esService.isIndexExist(indexName);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/String indexName",method = RequestMethod.POST)
//    public Boolean deleteIndex(String indexName) {
//        return esService.deleteIndex(indexName);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/createByFluentDSL",method = RequestMethod.POST)
//    public <T> IndexResponse createByFluentDSL(String indexName, String indexId, T document) {
//        return esService.createByFluentDSL(indexName, indexId, document);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/createByBuilderPattern",method = RequestMethod.POST)
//    public <T> IndexResponse createByBuilderPattern(String indexName, String indexId, T document) {
//        return esService.createByBuilderPattern(indexName, indexId, document);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/createByJson",method = RequestMethod.POST)
//    public Boolean createByJson(String indexName, String indexId, String jsonContent) {
//        return esService.createByJson(indexName, indexId, jsonContent);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/createAsync",method = RequestMethod.POST)
//    public <T> void createAsync(String indexName, String indexId, T document, BiConsumer<IndexResponse, Throwable> action) {
//        esService.createAsync(indexName, indexId, document, action);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/bulkCreate",method = RequestMethod.POST)
//    public <T> BulkResponse bulkCreate(String indexName, List<T> documents) {
//        return esService.bulkCreate(indexName, documents);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/getById",method = RequestMethod.POST)
//    public <T> T getById(String indexName, String documentId, Class<T> tClass) {
//        return esService.getById(indexName, documentId, tClass);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/updateById",method = RequestMethod.POST)
//    public <T> Result updateById(String indexName, String documentId, Class<T> tClass, Map<String, Object> map) {
//        return esService.updateById(indexName, documentId, tClass, map);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/getObjectNodeById",method = RequestMethod.POST)
//    public ObjectNode getObjectNodeById(String indexName, String documentId) {
//        return esService.getObjectNodeById(indexName, documentId);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/deleteById",method = RequestMethod.POST)
//    public Boolean deleteById(String indexName, String documentId) {
//        return esService.deleteById(indexName, documentId);
//    }
//
//    @ResponseBody
//    @RequestMapping(value="/bulkDeleteByIds",method = RequestMethod.POST)
//    public BulkResponse bulkDeleteByIds(String indexName, List<String> documentIds) {
//        return esService.bulkDeleteByIds(indexName, documentIds);
//    }
}
